package com.wx.wxsecondskill.controller;

import com.wx.core.response.JsonData;
import com.wx.wxsecondskill.po.User;
import com.wx.wxsecondskill.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import static com.wx.commons.constant.CommonConstant.BusinessOperation.ADD_SUCCESS;

/**
 * @ClassName SampleController
 * @Author wx
 * @Description 例子
 * @Date 2018-11-14-22:07
 */
@Controller
@RequestMapping("/demo")
public class SampleController {
    @Autowired
    private UserService userService;

    @ResponseBody
    @GetMapping("/db/get")
    public JsonData dbGet() {
        User user = userService.getFirstUser();
        return JsonData.ResultMsgSuccess(user);
    }

     /**
      * @methodName: dbTx
      * @author: wx
      * @description: 生成5万条用户信息
      * @param
      * @date: 2018/11/17
      * @return: com.wx.core.response.JsonData
      */
    @ResponseBody
    @PostMapping("/db/tx")
    public JsonData dbTx() {
        userService.tx();
        return JsonData.ResultMsgSuccess(ADD_SUCCESS);
    }
}
